package com.dbapp.shopping.controller;

import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.security.Principal;

@Controller
@RequestMapping("/")
public class UserController {

    @GetMapping("/login")
    public String login(Principal principal) {
        Authentication authentication = (Authentication) principal;
        if (principal != null && authentication.isAuthenticated()) {
            return "redirect:/";
        }
        return "login";
    }
}
